package com.zhongzhi.util;

import java.io.IOException;

import com.zhongzhi.common.Common;

import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.stage.Window;
import javafx.stage.WindowEvent;
import lombok.extern.log4j.Log4j;
@Log4j
public class PageUtil {
	public void setPage(String uri,String name) {
		//打开画面代码
		Parent root;
		try {
			root = FXMLLoader.load(getClass().getResource(uri));
			Scene scene = new Scene(root);
			Stage stage = new Stage();
			stage.setScene(scene);
			stage.setTitle(name);
			stage.getIcons().add(new Image("/Images/tb.png"));
			stage.setResizable(false);//窗口不可改变大小
			stage.initModality(Modality.APPLICATION_MODAL);//窗口模态
			stage.show();//窗口出现
		} catch (IOException e) {
			log.error("打开窗口:"+name+"失败:"+e);
		}
	}
	
	public Stage setPage2(String uri,String name) {
		//打开画面代码
		Parent root;
		try {
			root = FXMLLoader.load(getClass().getResource(uri));
			Scene scene = new Scene(root);
			Stage stage = new Stage();
			stage.setScene(scene);
			stage.setTitle(name);
			stage.getIcons().add(new Image("/Images/tb.png"));
			stage.setResizable(false);//窗口不可改变大小
			stage.initModality(Modality.APPLICATION_MODAL);//窗口模态
//			stage.setAlwaysOnTop(true);
			stage.initStyle(StageStyle.UNIFIED);
			stage.show();//窗口出现
			return stage;
		} catch (IOException e) {
			log.error("打开窗口:"+name+"失败:"+e);
		}
		return null;
	}
	
	
}
